<?php
// no direct access
defined('_JEXEC') or die;
$templatepath	= JURI::base().'templates/'.JFactory::$application->getTemplate();
JPluginHelper::importPlugin('content','loadmodule');
$dispatcher	= JDispatcher::getInstance();
$db =& JFactory::getDBO();

$article =JTable::getInstance('content');
$article->load(69);
$article->text=strip_tags($article->introtext);//banner embed
$article->params=array();
$dispatcher->trigger('onContentPrepare', array ('com_content.article', &$article, &$article->params));

$tmplpath = JURI::base().'/templates/fitplan';

$db->setQuery("SELECT name, clickurl, description, params FROM `#__banners` WHERE catid=3 ORDER BY ordering");
$banners = $db->loadObjectList();

$db->setQuery("SELECT u.image, u.name, u.description FROM #__users u INNER JOIN #__user_usergroup_map ugm ON u.id = ugm.user_id WHERE ugm.group_id=5");
$users = $db->loadObjectList();

preg_match("#<div.*?(<a.*?){2}</div>#", $article->fulltext, $matches);
$article->fulltext=str_replace($matches[0], "[V]", $article->fulltext);
$matches=str_replace(array("max-width: 320px;", "font-size: 16px; line-height"), array("max-width: 300px;", "font-size: 12px; line-height"), $matches[0]);
$article->fulltext=str_replace("[V]", $matches, $article->fulltext);
?>

<div class="eachBox welcome-box clearfix">
	<div id="banner" class="clearfix">
		<?php echo $article->text;?>
	</div><!--#banner-->
	<div class="cont-box">
		<h1 style="text-align: center">
			<?php echo preg_replace("# (.+)#",' <span class="green">$1</span>',$article->title)?>
		</h1>
		<?php echo $article->fulltext;?>
	</div>
</div><!--.welcome-box-->

<div class="eachBox video-box clearfix">
	<div class="wrapper-iframe">
<?php
	$article->load(1);
	preg_match("{(.+)}", $article->introtext, $matches);
	$text = str_replace($matches[0], '', $article->introtext);
	echo preg_replace("#\<p>{youtube .*?=(.+)\}#",'<iframe width="314" height="235" src="//www.youtube.com/embed/$1" frameborder="0" wmode="opaque" allowfullscreen></iframe>',$matches[0]);
?>
	</div>
<?php
	$article1=clone $article;
	$article1->load(2);
?>
	<div class="cont-box">
		<h2>
			<?php echo $article1->title;?>
		</h2>
		<?php echo $article1->introtext;?>
	</div>
</div><!--.video-box-->
<div class="eachBox clearfix">
	<div class="cont-box">
		<?php echo $text;?>
		<div class="wrap-social">
			<a class="bntFace" href="https://www.facebook.com/fitplan.dk">
				<img src="<?php echo $tmplpath; ?>/src_mobile/images/btnFaceboock.png" style="width:233px">
			</a><img src="<?php echo $tmplpath; ?>/src_mobile/images/or.png"	 style="width:24px">
			<a class="bntGplus" href="https://plus.google.com/u/0/117716894165331314266/posts">
				<img src="<?php echo $tmplpath; ?>/src_mobile/images/btnGoogle-plus.png" style="width:40px">
			</a>
		</div>
	</div>
</div><!--.eachBox-->
<div class="eachBox teachers-box clearfix">
	<div class="cont-box" style="width:90%">
		<h2>
			SUCCESHISTORIER
		</h2>
		<ul class="user list-teacher clearfix">
			<?php
			foreach($users as $user)
			{
				?>
				<li>
					<a class="picPro">
						<img src="<?php echo JURI::base().$user->image; ?>">
					</a>
					<h6>
						<?php echo $user->name;?>
					</h6>
					<?php echo $user->description;?>
				</li>
				<?php
			}?>
		</ul>
	</div>
</div>